Skip to content

Check if not a left-click, then bail out of onStart#2087

Merged
alexcjohnson merged 5 commits into
plotly:masterfrom
AlexVvx:disable-drag-on-rightclick
Oct 16, 2017
Merged

Check if not a left-click, then bail out of onStart#2087
alexcjohnson merged 5 commits into
plotly:masterfrom
AlexVvx:disable-drag-on-rightclick

Conversation

@AlexVvx

@AlexVvx AlexVvx commented Oct 13, 2017

Copy link
Copy Markdown

Related to #248

This PR adds check in dragElement. On start, if not a left-click, then bail out of onStart. The purpose of this check is to let developers to use their own context menu instead of browser context menu. Without that check there were no possibility to see 'contextmenu' event when click inside plot container.

@AlexVvx
AlexVvx force-pushed the disable-drag-on-rightclick branch from 3eed451 to 0a4bb0d Compare October 13, 2017 21:13
@AlexVvx
AlexVvx force-pushed the disable-drag-on-rightclick branch from 0a4bb0d to 7e6e899 Compare October 13, 2017 21:14
Comment thread test/jasmine/tests/dragelement_test.js Outdated
var options = { element: this.element, gd: this.gd };
dragElement.init(options);

options.element.onmousedown({button: 2})

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, that it's a best way to emulate right click, however I can't see any other options.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like in mouse_event we have buttons but if we add button the same way it should allow right-click simulation?

Alex Vinober added 3 commits October 16, 2017 11:25
… disable-drag-on-rightclick

# Conflicts:
#	src/components/dragelement/index.js
#	test/jasmine/tests/dragelement_test.js
@AlexVvx

AlexVvx commented Oct 16, 2017

Copy link
Copy Markdown
Author

I wasn't able to find 'Buttons' in ie spec, but it works well in ie9, so I changed everything to 'buttons'.

dragElement.init(options);

mouseEvent('mousedown', this.x, this.y, { buttons: 2 });
expect(countCoverSlip()).toEqual(0);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Very clear correspondence to the test above. Two last changes I would suggest, then I think this is ready to go:

  • 🌴 Can you move countCoverSlip out one scope so we don't have to repeat it?
  • Can you continue through mouseup as in the test below, and verify that handleClick has not been called? (that one ironically looks annoying to DRY 🌴 so you can just repeat the pieces you need.)

@AlexVvx AlexVvx Oct 16, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thank you

…at handler won't being called on right click
@etpinard etpinard added status: reviewable bug something broken labels Oct 16, 2017
@alexcjohnson

Copy link
Copy Markdown
Collaborator

Fantastic @AlexVvx - thanks for the PR and updates! 💃 - we're calling this a bug fix, so it can go in the release we're planning later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug something broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants